package com.duoduo.nacos.order.controller;

import com.duoduo.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: duoduo-nacos
 * @description: 订单接口
 * @author: 拾光！
 * @create: 2021-06-20 09:32
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
    /**
     * 根据用户id查询订单信息
     * @param userId
     * @return
     */
    @GetMapping("/findOrderByUserId/{userId}")
    public R findOrderByUserId(@PathVariable("userId") Integer userId) {

//        try {
//            Thread.sleep(8000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        //模拟异常
//        if(userId==5){
//            throw new IllegalArgumentException("非法参数异常");
//        }

        log.info("根据userId:"+userId+"查询订单信息");
        return R.ok().put("orders", userId);
    }
}
